<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="utf-8" />
<title>E:only-of-type</title>
<meta name="description" content="CSS3参考手册之: E:only-of-type" />
<meta name="keywords" content="E:only-of-type, css3选择符, css3, css3参考手册" />
<meta name="author" content="Joy Du(飘零雾雨), dooyoe@gmail.com, www.doyoe.com" />
<meta name="robots" content="all" />
<!--[if lte IE 8]>
<script src="../../js/html5.js"></script>
<![endif]-->
<link rel="stylesheet" href="../../skin/article.css" />
</head>
<body>
<nav id="guide" class="g-mod">
	<div class="from">
		<a href="http://css.doyoe.com/" target="_blank">CSS3参考手册</a>
		<span>&#187;</span>
		<a href="../index.htm">选择符列表</a>
		<span>&#187;</span>
		<a href="index.htm" id="category" rel="selectors/pseudo-classes" name="only-of-type">伪类选择符</a>
		<span>&#187;</span>
	</div>
	<div class="to">
		<span class="label">相关内容：</span>
		<div class="g-combobox g-transition">
			<a href="?" class="g-transition target">
				<strong>其它伪类选择符</strong>
				<span>选择其它项<!--[if lte IE 7]><ins>IE7 and earlier, Get to die</ins><![endif]--></span>
			</a>
			<div class="g-transition list">
				<ul>
					<!-- 插入分类快速导航 -->
				</ul>
			</div>
		</div>
	</div>
</nav>
<header id="hd">
	<section id="title" class="g-mod">
		<h1 class="tit">E:only-of-type</h1>
		<ul class="info">
			<li><strong>版本：CSS3</strong></li>
		</ul>
		<!-- 插入浏览器信息 -->
	</section>
</header>
<section id="bd">
	<section id="syntax" class="g-mod g-attr">
		<h2 class="tit">语法：</h2>
		<div class="cont">
			<p><strong>E:only-of-type</strong> { sRules }</p>
		</div>
	</section>
	<section id="intro" class="g-mod g-attr">
		<h2 class="tit">说明：</h2>
		<div class="cont">
			<strong>匹配父元素的所有子元素中唯一的那个子元素E。</strong>
			<p>需要注意2个要点：</p>
			<ul>
				<li>首先，因为匹配的是父元素的子元素，这意味着E元素必须作为某个元素的子元素存在（E元素的父元素最高是html，也就是说E元素最高是body，这表示任何非html的元素都符合这个约束，因为html元素是根元素）。</li>
				<li>
					<p>其次，父元素可以有多个子元素，但其中的子元素E必须是唯一的，不能出现多个。</p>
					<strong>来看下面的例子：</strong>
					<div class="gquote">
						<p class="gquote-tit"><strong>有如下一段CSS：</strong></p>
						<blockquote class="gquote-cont"><code><xmp>.demo span:only-of-type { color: #f00; }</xmp></code></blockquote>
						<p class="gquote-info">该选择器表示要匹配 .demo 下唯一的span元素</p>
					</div>
					<div class="gquote">
						<p class="gquote-tit"><strong>示例一，假设有如下HTML：</strong></p>
						<blockquote class="gquote-cont"><code><xmp><div class="demo">
	<span>span1</span>
</div></xmp></code></blockquote>
						<p class="gquote-info">毫无疑问，因为span1是 .demo 唯一的子元素，所以span1会被命中</p>
					</div>
					<div class="gquote">
						<p class="gquote-tit"><strong>示例二，假设有如下HTML：</strong></p>
						<blockquote class="gquote-cont"><code><xmp><div class="demo">
	<p>p1</p>
	<span>span1</span>
</div></xmp></code></blockquote>
						<p class="gquote-info">可以看到span1也会被命中，虽然此例中.demo有2个子元素，但span1是.demo唯一的span子元素</p>
					</div>
					<div class="gquote">
						<p class="gquote-tit"><strong>示例三，假设有如下HTML：</strong></p>
						<blockquote class="gquote-cont"><code><xmp><div class="demo">
	<p>p1</p>
	<span>span1</span>
	<span>span2</span>
</div></xmp></code></blockquote>
						<p class="gquote-info">此时span将不会被命中，因为.demo有2个span子元素，不满足唯一性要求。</p>
					</div>
				</li>
			</ul>
		</div>
	</section>
	<section class="g-mod g-attr" id="compatible">
		<h2 class="tit">兼容性：</h2>
		<div class="cont">
			<ul class="support-type">
				<li><span class="support">浅绿</span> = 支持</li>
				<li><span class="unsupport">红色</span> = 不支持</li>
				<li><span class="partsupport">粉色</span> = 部分支持</li>
			</ul>
			<table class="g-data">
				<thead>
					<tr>
						<th>IE</th>
						<th>Firefox</th>
						<th>Chrome</th>
						<th>Safari</th>
						<th>Opera</th>
						<th>iOS Safari</th>
						<th>Android Browser</th>
						<th>Android Chrome</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td class="unsupport">6.0-8.0</td>
						<td class="support" rowspan="2">2.0+</td>
						<td class="support" rowspan="2">4.0+</td>
						<td class="support" rowspan="2">3.1+</td>
						<td class="support" rowspan="2">3.5+</td>
						<td class="support" rowspan="2">3.2+</td>
						<td class="support" rowspan="2">2.1+</td>
						<td class="support" rowspan="2">18.0+</td>
					</tr>
					<tr>
						<td class="support">IE9.0+</td>
					</tr>
				</tbody>
			</table>
		</div>
	</section>
	<section id="example" class="g-mod g-attr">
		<h2 class="tit">示例：</h2>
		<div class="cont">
			<textarea cols="90" rows="10">
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="utf-8" />
<title>结构性伪类选择符 E:only-of-type_CSS参考手册_web前端开发参考手册系列</title>
<meta name="author" content="Joy Du(飘零雾雨), dooyoe@gmail.com, www.doyoe.com" />
<style>
p:only-of-type {
	color: #f00;
}
</style>
</head>
<body>
<div class="test">
	<p>结构性伪类选择符 E:only-of-type</p>
</div>
</body>
</html>
			</textarea>
			<p><input type="button" value="运行" class="g-btn g-btn-sure" /></p>
		</div>
	</section>
</section>
<footer id="ft">
	<aside id="rights" class="g-mod">
		<!-- 插入浏览器及版权信息 -->
	</aside>
</footer>
<script src="../../js/jquery.js"></script>
<script src="../../js/inner.js"></script>
</body>
</html>